import type { AppRouteModule } from '/@/router/types';
const IFrame = () => import('/@/views/iFrames/FrameBlank.vue');

import { LAYOUT } from '/@/router/constant';
let frameSrc = 'http://192.168.0.11:8055/swagger';
if (process.env.NODE_ENV === 'production') {
  const loaclhostNames = window.location.href.split('/');
  // 如果配置访问url则取配置文件的
  const baseURL = sessionStorage.getItem('baseURL');
  if (baseURL) {
    frameSrc = baseURL + '/swagger';
  } else if (loaclhostNames?.length > 0 && loaclhostNames[2]) {
    const domain = loaclhostNames[2].split(':')[0];
    frameSrc = `http://${domain}:8055/swagger`;
  }
}

const project: AppRouteModule = {
  id: '10',
  path: '/rabbit',
  name: 'Rabbit',
  component: LAYOUT,
  redirect: '/rabbit/index',
  meta: {
    orderNo: 10,
    icon: 'mdi:server',
    title: 'API',
  },
  children: [
    {
      id: '10-1',
      path: 'index',
      name: 'RabbitIndexPage',
      component: () => import('/@/views/project/rabbit/index.vue'),
      meta: {
        title: 'RabbitMQ服务',
      },
    },
    {
      id: '10-2',
      path: 'mqtt',
      name: 'MqttPage',
      component: () => import('/@/views/project/rabbit/mqtt.vue'),
      meta: {
        title: 'MQTT服务',
      },
    },
    {
      id: '10-3',
      path: 'doc',
      name: 'Doc',
      component: IFrame,
      meta: {
        frameSrc,
        title: 'WebApi',
      },
    },
  ],
};

export default project;
